<template>
  <d2-container>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="12">
          <el-form-item label="下拉选择" prop="field103">
            <el-select v-model="formData.field103" placeholder="请选择下拉选择" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in field103Options" :key="index" :label="item.label"
                         :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="单行文本" prop="field104">
            <el-input v-model="formData.field104" placeholder="请输入单行文本" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

  </d2-container>
</template>

<script>
export default {
  components: {},
  props: [],
  data () {
    return {
      formData: {
        field103: undefined,
        field104: undefined
      },
      rules: {
        field103: [{
          required: true,
          message: '请选择下拉选择',
          trigger: 'change'
        }],
        field104: [{
          required: true,
          message: '请输入单行文本',
          trigger: 'blur'
        }]
      },
      field103Options: [{
        label: '选项一',
        value: 1
      }, {
        label: '选项二',
        value: 2
      }]
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    submitForm () {
      this.$refs.elForm.validate(valid => {
        // eslint-disable-next-line no-useless-return
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm () {
      this.$refs.elForm.resetFields()
    }
  }
}

</script>
